<?php
/**
 * Created by PhpStorm.
 * User: zhangxiaodong
 * Date: 2018/3/21
 * Time: 11:25
 */
require_once dirname(dirname(__FILE__)) . '/include/common.inc.php';
require_once INCLUDE_ROOT_PATH . 'file_server.class.php';

$shop_id = isset($_REQUEST['shop_id']) ? $_REQUEST['shop_id'] : '';	//才俊佳丽ID
$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : '';	//操作，view在线查看，download下载
$filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : '';	//要查看或下载的文件名
$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';	//token验证

$width = isset($_REQUEST['width']) ? $_REQUEST['width'] : 1024;	//将图片缩放的最大宽度
$height = isset($_REQUEST['height']) ? $_REQUEST['height'] : 1024;//将图片缩放的最大高度
if (empty($shop_id) || !is_numeric($shop_id) || $shop_id <= 0 || $token != md5($shop_id . 'honoraryfigure_view'))
{
    $result = false;
}
else
{
    $file_dir = HONORARYFIGURE . $shop_id . '/';
    $filepath = $file_dir . $filename;
    $File_server = new File_server();
    switch ($act)
    {
        case 'view':
            $result = $File_server->view_image($filepath,$width,$height);
            break;

        case 'download':
            $result = $File_server->download($filepath);
            break;

        default:
            $result = false;
            break;
    }
}
var_dump($result);die;
exit($result);
?>